<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">订单用户</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="user_keys" placeholder="请输入手机或昵称" value="{$get.user_keys|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">推荐用户</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="from_keys" placeholder="请输入手机或昵称" value="{$get.from_keys|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">订单单号</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="order_no" placeholder="请输入订单单号" value="{$get.order_no|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">发货单号</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="truck_send_number" placeholder="请输入发货单号" value="{$get.truck_send_number|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">订单状态</label>
        <label class="layui-input-inline">
            <select class="layui-select" name="status">
                <option value=''>- 全部订单 -</option>
                {foreach ['1'=>'预购订单','2'=>'等待支付','3'=>'等待审核','4'=>'等待发货','5'=>'已经发货','6'=>'已经完成','0'=>'已经取消'] as $k=>$v}
                {if input('status') eq $k.''}
                <option selected value="{$k}">{$v}</option>
                {else}
                <option value="{$k}">{$v}</option>
                {/if}{/foreach}
            </select>
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">付款状态</label>
        <label class="layui-input-inline">
            <select class="layui-select" name="payment_status">
                <option value=''>-- 全部 --</option>
                {foreach ['0'=>'等待支付','1'=>'已经支付'] as $k=>$v}
                {if input('payment_status') eq $k.''}
                <option selected value="{$k}">{$v}</option>
                {else}
                <option value="{$k}">{$v}</option>
                {/if}{/foreach}
            </select>
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">支付方式</label>
        <label class="layui-input-inline">
            <select class="layui-select" name="payment_type">
                <option value=''>-- 全部 --</option>
                {foreach $payments as $k=>$v}
                {if input('payment_type') eq $k.''}
                <option selected value="{$k}">{$v.name}</option>
                {else}
                <option value="{$k}">{$v.name}</option>
                {/if}{/foreach}
            </select>
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">下单时间</label>
        <label class="layui-input-inline">
            <input class="layui-input" data-date-range name="create_at" placeholder="请选择下单时间" value="{$get.create_at|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">支付时间</label>
        <label class="layui-input-inline">
            <input class="layui-input" data-date-range name="payment_datetime" placeholder="请选择支付时间" value="{$get.payment_datetime|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">收货姓名</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="truck_address_name" placeholder="请输入收货姓名" value="{$get.truck_address_name|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">收货手机</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="truck_address_phone" placeholder="请输入收货手机" value="{$get.truck_address_phone|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">收货地址</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="truck_address_content" placeholder="请输入收货省份" value="{$get.truck_address_content|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <button class="layui-btn layui-btn-primary" type="submit"><i class="layui-icon">&#xe615;</i> 搜 索</button>
        <button class="layui-btn layui-btn-primary" data-form-export="{:url('index')}?type={$type|default=''}" type="button">
            <i class="layui-icon layui-icon-export"></i> 导 出
        </button>
    </div>
</form>

<script>
    require(['excel'], function (excel) {
        excel.bind(function (data) {
            var items = [];
            items.push(['订单号', '用户手机', '用户姓名', '订单类型', '支付单号', '支付方式', '支付状态', '支付金额', '支付时间']);
            data.forEach(function (order) {
                items.push([
                    order.order_no,
                    order.user.phone,
                    order.user.username || order.user.nickname || '',
                    order.truck_type ? '虚拟商品' : '实物商品',
                    order.payment_trade || '',
                    order.payment_name || order.payment_type || '',
                    order.payment_status ? '已支付' : '未支付',
                    order.payment_amount || '0.00',
                    order.payment_datetime || '',
                ]);
            });
            return items;
        }, '用户订单记录');
    });
</script>